#ifndef TRANSACT_H
#define TRANSACT_H

#include <QWidget>
#include <qdialog.h>
#include "ui_transact.h"
#include <string.h>
#include "sql_Connector.h"
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <map>
using namespace std;

#define TRANS_WIDTH 404
#define TRANS_HEIGHT 266

class transact : public QDialog
{
	Q_OBJECT
private:
	vector<vector<string> > *stockDisplay_pointer;
	map<string,int> riskStock;
	map<string,int> transact_Items;
	vector<string>  atRiskItem;		// Item that <= min_stock after this transaction
	vector<vector<string>> toTransaction;
	enum {colItemID, colItemName, colItemCat, colItemManu, colItemPrice, colItemLocalStock, colItemMinStock, colItemBundleUnit};
	enum {barcod, quantit, cashi};
public:
	transact(QDialog *parent = 0);
	transact(vector<vector<string> > &stockDisplay_current,QDialog *parent = 0);
	~transact();
	public slots:
		void on_transact_Cancel_clicked();
		void on_transact_Item_add_clicked();
		void on_transact_Submit_clicked();
		void removeEntry(int index,int col);
private:
	Ui::transact ui;
	bool is_number(const std::string& s);
	int check_transact_syntax();
	double check_barcode(string barcode,string quantity,int ro,sql_Connector *contor);
	int check_cashier(string cId, int ro, sql_Connector *contor);
	void Initialize();
	void addAtRiskItem(Item *iI);
	void update_stock_Pointer(vector<string> tmp);
	int checkDuplicate(string barcod,int row);
	int mergeBarcode();
};

#endif // TRANSACT_H
